<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Home - BioCode</title>
    <style>
        .content-container {
            padding: 10px 14px;
        }

        #tool-nav-tab {
            padding: 0 15px;
            margin-bottom: 12px;
            background-color: #FAFAFA;
        }
    </style>
</head>
<body>
<div id="main">
    <div id="tool-header">
        <div class="row content-container" style="padding-bottom: 0">
            <div class="col-md-12">
                <h1 class="tool-title"><a href="${host}/tools/${tool.id}/show">${tool.name}</a>
                    <small>${tool.desc}</small>
                </h1>
            </div>
        </div>
        <ul class="nav nav-tabs" id="tool-nav-tab">
            <li><a href="${host}/tools/${tool.id}/show"><i class="fa fa-home"></i> Home</a></li>
            <li><a href="${host}/tools/${tool.id}/manual"><i class="fa fa-book"></i> Manual</a></li>
            <li class="active"><a href="${host}/tools/${tool.id}/releases"><i class="fa fa-download"></i> Downloads</a>
            </li>
            <li><a href="${host}/tools/${tool.id}/stat"><i class="fa fa-bar-chart"></i> Statistics</a></li>
        </ul>
    </div>
    <div class="content-container" style="padding-top: 0px">
        <form class="smv" id="new_release" enctype="multipart/form-data" action="${host}/tools/${tool.id}/releases/save"
              accept-charset="UTF-8" method="post">
            <div class="row">
                <div class="col-md-3">
                    <div class="form-group">
                        <label for="release_version">Version</label>
                        <input class="form-control"
                               data-rule="required|/^[a-zA-Z0-9.]+[a-zA-Z0-9]$/Only letter, dot and number are allowed. Ended with a letter or number|/\./Must contain at least one dot, such as 1.0"
                               type="text"
                               name="version" value="${release.version}"
                               id="release_version">
                    </div>
                    <div class="form-group">
                        <label for="release_Upload">Upload</label>
                        <input multiple="multiple"
                               name="file"
                               type="file" id="release_Upload">
                    </div>
                    <input type="submit" name="commit" value="Save" class="btn btn-primary" data-disable-with="Save">
                </div>
                <div class="col-md-8">
                    <%-- <div class="form-group">
                         <label for="release_note">Note</label>
                         <textarea class="form-control" name="release[note]" rows="20" id="release_note" aria-hidden="true"></textarea>
                     </div>--%>
                    <div class="form-group"><label for="release_note">Note</label>
                        <textarea class="tinymce" rows="20" name="note" id="release_note"
                                  aria-hidden="true">${release.note}</textarea></div>
                    <div class="form-group"><label>Files</label>
                        <c:if test="${fn:length(files)<1}">
                            <div class="empty-placeholder"><p>No files</p></div>
                        </c:if>
                        <c:if test="${fn:length(files)>0}">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="550px">File Name</th>
                                    <th width="100px">File Size</th>
                                    <th></th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach items="${files}" var="item">
                                <tr>
                                    <td>
                                        <a href="${host}/tools/${tool.id}/releases/${release.version}/file/download?filename=${item.fileName}">${item.fileName}</a>
                                    </td>
                                    <td>${item.fileLength} Bytes</td>
                                    <td><a href="${host}/tools/${tool.id}/releases/${release.version}/file/delete?filename=${item.fileName}">Delete</a>
                                    </td>
                                </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </c:if>
                    </div>

                </div>
            </div>
        </form>
    </div>


</div>
<script>
    var ue = UE.getEditor('release_note', {
        initialFrameHeight: 300,
        initialFrameWeight: 100
    });
    new SMValidator('form', {
        submit: function (valid, form) {
            if (valid) {

                form.submit();
            } else {
                alert(3);
            }

        }
    });

</script>
</body>

</html>
